package com.wz.project.ddjmsg.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.ddjmsg.domain.MsgDdj;
import com.wz.project.ddjmsg.service.IMsgDdjService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 堆垛机监控Controller
 * 
 * @author wz
 * @date 2024-01-04
 */
@Controller
@RequestMapping("/ddjmsg/ddjmsg")
public class MsgDdjController extends BaseController
{
    private String prefix = "ddjmsg/ddjmsg";

    @Autowired
    private IMsgDdjService msgDdjService;

//    @RequiresPermissions("ddjmsg:ddjmsg:view")
    @GetMapping()
    public String ddjmsg()
    {
        return prefix + "/ddjmsg";
    }

    /**
     * 查询堆垛机监控列表
     */
//    @RequiresPermissions("ddjmsg:ddjmsg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsgDdj msgDdj)
    {
        startPage();
        List<MsgDdj> list = msgDdjService.selectMsgDdjList(msgDdj);
        return getDataTable(list);
    }

    /**
     * 导出堆垛机监控列表
     */
//    @RequiresPermissions("ddjmsg:ddjmsg:export")
    @Log(title = "堆垛机监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsgDdj msgDdj)
    {
        List<MsgDdj> list = msgDdjService.selectMsgDdjList(msgDdj);
        ExcelUtil<MsgDdj> util = new ExcelUtil<MsgDdj>(MsgDdj.class);
        return util.exportExcel(list, "ddjmsg");
    }

    /**
     * 新增堆垛机监控
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存堆垛机监控
     */
    @RequiresPermissions("ddjmsg:ddjmsg:add")
    @Log(title = "堆垛机监控", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsgDdj msgDdj)
    {
        return toAjax(msgDdjService.insertMsgDdj(msgDdj));
    }

    /**
     * 修改堆垛机监控
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MsgDdj msgDdj = msgDdjService.selectMsgDdjById(id);
        mmap.put("msgDdj", msgDdj);
        return prefix + "/edit";
    }

    /**
     * 修改保存堆垛机监控
     */
    @RequiresPermissions("ddjmsg:ddjmsg:edit")
    @Log(title = "堆垛机监控", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsgDdj msgDdj)
    {
        return toAjax(msgDdjService.updateMsgDdj(msgDdj));
    }

    /**
     * 删除堆垛机监控
     */
    @RequiresPermissions("ddjmsg:ddjmsg:remove")
    @Log(title = "堆垛机监控", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msgDdjService.deleteMsgDdjByIds(ids));
    }
}
